<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        let reg = new RegExp('a')
        console.log(reg);

        // 字面量创建方式
        let reg1 = /bc/i

        let str = 'bcdefgA'

        console.log(reg1.test(str));

        // 邮箱验证
        let ereg = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/
        console.log(ereg.test('479058582'));
        // 身份证号
        let numreg = /\d{17}[\d|x]|\d{15}/
        console.log(numreg.test('000000000000000X'));
        // ip
        let ipreg =  /(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/
        console.log(ipreg.test('192.168.266.256'));

        // exec  检索字符串并返回第一个值
        console.log(reg1.exec(str));

        let str3 = 'anabacafar'
        // 使用正则表达式的方式进行全局替换
        console.log(str3.replace(/a/g,'x'));
        

        
        
        
    </script>
</body>
</html>